<template>
	<view>
		<view v-for="(item,index) in list" :key="index">
			<view class="list_">
				<view class="_a" @click="chat(item)">
					<view class="_abbr">
						<image :src="infor.id==item.uid?item.custom.avatar:item.user.avatar" class="_b"></image>
					</view>
					<view>
						<view class="_b_v">
							<p class="_b_p">{{infor.id==item.uid?item.custom.nickname:item.user.nickname}}</p>
							<p class="b_p">{{item.message==''?'图片':item.message}}</p>
						</view>
					</view>
				</view>
				<view class="_c">
					<view class="_c1">
						<p>{{item.created_at}}</p>
					</view>
					<view class="_c2">
						<u-button type="primary" text="删除" size="mini" @click="del_talk(item)"></u-button>
					</view>
				</view>

			</view>
			<view class="line">
				<u-line></u-line>
			</view>
		</view>

		<view class="icon" v-if="list.length==''">
			<u-empty mode="message" icon="chat-fill" >
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: '../../static/logo.png',
				list: [],
				infor: {}
			}
		},
		onLoad() {
			this.infor = uni.getStorageSync("infor")
			this.get_data()
		},
		methods: {
			get_data() {
				let that = this
				this.$model.get("user/common/get_chat_list").then(res => {
					that.list = res.data
				})
			},
			del_talk(item) {
				let that = this
				this.$model.get("user/del_talking?message_id=" + item.message_id).then(res => {
					if (res.code == 200) {
						that.get_data()
					}
				})
			},
			chat(item) {
				let id = this.infor.id == item.uid ? item.cid : item.uid
				let type = item.type == "custom" ? "custom" : ''
				uni.navigateTo({
					url: "./chat?id=" + id + "&user_type=" + type
				})
			}
		}
	}
</script>

<style>
	.list_ {
		margin-top: 10rpx;
	}

	._a {
		width: 650rpx;
	}

	._abbr {
		width: 110rpx;
		margin: 0 20rpx 0 15rpx;
	}

	._b {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50rpx;
	}

	._b_v {
		width: 510rpx;
		float: right;
		margin: -100rpx 20rpx 0 180rpx;
	}

	._b_p {
		color: #000;
		font-size: 40rpx;
	}

	.b_p {
		color: #606266;
		font-size: 30rpx;
	}

	._c {
		width: 300rpx;
		float: right;
		margin-top: -100rpx;

	}

	._c p {
		color: #606266;
		font-size: 30rpx;
	}

	._c1 {
		width: 160rpx;
		float: left;
	}

	._c2 {
		width: 100rpx;
		float: right;
	}

	.line {
		margin-top: 5rpx;
	}

	.line u-line {
		color: #606266;
	}
	.icon{
		margin-top: 270rpx;
	}
</style>
